package study.jsm.com.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import study.jsm.com.myapplication.Utils.ToastUtils;


public class ListActivity extends Activity {

    ListView lv_fruits;

    String FruitName[]={"苹果","香蕉","樱桃","葡萄","芒果","桔子","梨","菠萝","草莓","西瓜"};
    Activity activity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = this;
        setContentView(R.layout.activity_list);

        lv_fruits = findViewById(R.id.lv_fruits);
//        ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line,FruitName);
//        lv_fruits.setAdapter(arrayAdapter);
        lv_fruits.setOnItemClickListener(new AdapterView.OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ToastUtils.showToast(activity,FruitName[i]);
            }
        });
    }
}
